<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/m/include/init_mobile.jsp" %>
<%
	String member_id	= StringUtil.nvl(request.getParameter("id"));
	if (!"".equals(member_id)) {
		RequestDispatcher rd = request.getRequestDispatcher("/m/member/memberInfo.jsp");
		rd.forward(request, response);
		return;
	}


	String nextURL 		= StringUtil.nvl(request.getParameter("next_url"));

%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
	<title><%= HOME_NAME %></title>
	<%@ include file="/m/include/cssnjs.jsp"  %>
	<link rel="stylesheet" href="/css/jquery.mobile-1.4.2.min.css"/>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#header-nav li:nth-child(4)').addClass('on');
	});
	
	function fnLogin() {
		$.ajax({
			url: '/member/login.do',
			type: "POST",
		    dataType: 'json',
		    data:$('#frm').serialize(),
		    error: function(data, status, err){
		    	cfShowModal(err);
		    },
			success: function(data){
				if (data.result) {
				<%	if (os.equals("android")) {	%>
						window.android.loginSuccess(document.frm.member_id.value);
				<%		if ("".equals(nextURL)) {	%>
							document.location.href = "./memberInfo.jsp?os=<%=os%>&id=" + document.frm.member_id.value;
				<%		} else {	%>
							document.location.href = "<%= nextURL %>&os=<%=os%>";
				<%		}	%>
				<%	} else if (os.equals("ios")) {	%>
						window.location="jscall:loginSuccess:" + document.frm.member_id.value;
						document.location.href = "./memberInfo.jsp?os=<%=os%>&id=" + document.frm.member_id.value;
				<%	} else {	%>
						document.location.href = "<%=nextURL%>";
				<%	}	%>
				} else {
					cfShowModal(data.message);
				}
		    }
		});
		
		return false;
	}
	
	function fnFindPassword() {
		document.location.href = "./findPassword.jsp?os=<%=os%>";
	}
	
	function fnMemberRegist() {
		document.location.href = "./memberRegist.jsp?os=<%=os%>";
	}
	
	
	</script>
</head>
<body>
	<div id="wrap" class="ui-page-theme-a">
		<%@ include file="/m/include/header.jsp"  %>
		<div id="contents">
		
			<h2>로그인</h2>
			<div id="login">
            	<form name="frm" id="frm" method="get" action="" onsubmit="return fnLogin()">
	        		<div class="ui-input-search ui-body-inherit ui-corner-all ui-input-has-clear">
		        		<input type="text" name="member_id" value="" placeholder="이메일"/>
		        	</div>
		        	<div class="ui-input-search ui-body-inherit ui-corner-all ui-input-has-clear">
		        		<input type="password" name="member_pw" value="" placeholder="비밀번호"/>
		        	</div>
		        	<div class="ui-btn ui-input-btn ui-btn-active ui-corner-all ui-shadow">
						로그인<input type="image" alt="로그인" value="로그인"  />
					</div>
        		</form>
	        	<div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
					비밀번호찾기<input type="button" alt="비밀번호찾기" value="비밀번호찾기" onclick="fnFindPassword()"/>
				</div>
	        	<div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
					회원가입<input type="button" alt="회원가입" value="회원가입" onclick="fnMemberRegist()"/>
				</div>
			</div>
		</div>
		<%@ include file="/m/include/footer.jsp"  %>	
		
		
				
	</div>

</body>

</html>









